<?php
namespace app\admin\controller;
use think\Controller;
use think\Session;


class Login
{
    public function index()
    {

        if (request()->isAjax()) {
            $data = input('post.');
            $model = new \app\admin\Model\Login();
            if ($data['adminuser'] == false) {
                return json(['status' => 1, 'msg' => '登录名不能为空']);
            }
            if ($data['adminpassword'] == false) {
                return json(['status' => 1, 'msg' => '登录密码不能为空']);
            }

            $userStatus = $model->cheUsedStatus($data);
            if ($userStatus == true) {
                if ($userStatus['a_status'] != 1) {  //判断是否禁用使用
                    return json(['status' => 3, 'msg' => '账户已禁用,请联系管理处理此帐号!']);
                } else {
                    session('aid_admin', $userStatus);
                    return json(['status' => 2, 'msg' => '登陆成功', 'url' => url('Index/index')]);
                }
            } else {
                return json(['status' => 1, 'msg' => '账户不存在或密码有错,请重新输入!']);
            }
        }
        return view();
    }
}
